Example usage
struct Action { ubyte fromX, fromY, toX, toY; } struct BoardState { Action[] actions; } struct AssignColor { black, white } alias ChessNetController = NetController!(MarkNetData!( Action, AssignColor, BoardState )); ChessNetController c = new ChessNetController(getNetworkInterface); c.connect(NetIPAddress("127.0.0.1", 10_000)); c.on_connect(() { c.sendData([BoardState()]); }); c.on_disconnect(() { logg("Waiting for other player to connect..."); }); with(c.poll) { switch(typeID) { case Types.disconnect: //Disconnect event has no data break; case Types.Action: Action act = getAction(); break; case Types.AssignColor: AssignColor c = getAssignColor(); break; default: //Received an invalid typeID. break; } }
See Implementation
Example usage